/**
 * 
 */
package design_pattern.visitor.pc;

import java.util.Vector;

/**
 * @author linzq
 * 
 */
public class Composite extends Equipment {

  protected Vector parts = new Vector(10);

  @Override
  public void accept(Visitor v) {
    for (int i = 0; i < parts.size(); i++) {
      ((Equipment) parts.get(i)).accept(v);
    }

  }

  @Override
  public float price() {
    float total = 0.0f;
    for (int i = 0; i < parts.size(); i++) {
      total += ((Equipment) parts.get(i)).price();
    }
    return 0;
  }

  public void add(Equipment e) {
    parts.add(e);
  }

}
